#include "analysisform.h"
#include "ui_analysisform.h"
#include <QPainter>
#include <QStyleOption>

AnalysisForm::AnalysisForm(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::AnalysisForm)
{
    ui->setupUi(this);
    this->setFixedHeight(160);
    this->setProperty("form","backgroundform");
    ui->leftBorderForm->SetLabelIcon("analysis");
}

AnalysisForm::~AnalysisForm()
{
    delete ui;
}

void AnalysisForm::UpdateShowType(int type)
{
    ui->leftBorderForm->UpdateShowType(type);
}

void AnalysisForm::paintEvent(QPaintEvent *event)
{
    QStyleOption opt;
    opt.init(this);
    QPainter painter(this);
    style()->drawPrimitive(QStyle::PE_Widget,&opt,&painter,this);
    QWidget::paintEvent(event);
}

void AnalysisForm::on_toolButton_sensorView_clicked(bool checked)
{
    if(!checked)
    {
        ui->toolButton_sensorView->setIcon(QIcon(":/res/AnalysisForm/toolButton_sensorView.png"));
    }
    else
    {
        ui->toolButton_sensorView->setIcon(QIcon(":/res/AnalysisForm/toolButton_sensorView_checked.png"));
    }
}

void AnalysisForm::on_toolButton_image_clicked(bool checked)
{
    if(!checked)
    {
        ui->toolButton_image->setIcon(QIcon(":/res/AnalysisForm/toolButton_image.png"));
    }
    else
    {
        ui->toolButton_image->setIcon(QIcon(":/res/AnalysisForm/toolButton_image_checked.png"));
    }
}

void AnalysisForm::on_toolButton_value_clicked(bool checked)
{
    if(!checked)
    {
        ui->toolButton_value->setIcon(QIcon(":/res/AnalysisForm/toolButton_value.png"));
    }
    else
    {
        ui->toolButton_value->setIcon(QIcon(":/res/AnalysisForm/toolButton_value_checked.png"));
    }
}

void AnalysisForm::on_toolButton_contractExpand_clicked(bool checked)
{
    ui->widget_hide->setHidden(!checked);
    if(checked)
    {
        this->setFixedHeight(160);
        ui->widget->setFixedHeight(100);
    }
    else
    {
        this->setFixedHeight(130);
        ui->widget->setFixedHeight(50);
    }
}
